<?php

class BWEvent extends BEntityWithGroup {

    public $name = 'none';
    public $title = 'no title';
    public $description;
    public $startTime;
    public $endTime;
    public $creator;
    public $messages = array();
    public $data = array();
    public $mediaManager = null;

    public function getPropertyToColumnMapList($data = NULL) {
        $mapList = parent::getPropertyToColumnMapList($data);
        $mapList['startTime'] = 'start_time';
        $mapList['endTime'] = 'end_time';
        return $mapList;
    }

    public function getModelClass($data = NULL) {

        
        return 'BEMEvent';
    }
     public function save($eventData,$context = null) {
        if ($this->spaceId <= 0)
            $this->spaceId = Blyn::app()->getActiveSpace()->getId();
        if ($this->appId <= 0)
            $this->appId = $appId = Blyn::app()->getActiveApp()->getId();
        if ($this->creatorId <= 0)
            $this->creatorId = $creatorId = Blyn::app()->getCurrentUser()->getId();
        if ($this->createTime == NULL)
            $this->createTime = time();
        if ($this->amount == 0)
            $this->amount = 1; 
        if($eventData->Id>0){  
                $this->name = $eventData->name;
                $this->title = $eventData->title;
                $this->description = $eventData->description;
	        $this->starttime = $eventData->start_time;
	        $this->endtime = $eventData->end_time;
		$this->creator = $eventData->event_creator;
		$this->message = $eventData->event_message;
	        $this->data = $eventData->data;       
        }
        parent::save($context);
            
        
    }

    public function getModelClassAsGroupMember($data = NULL) {
        return 'BEMEventGroupMember';
    }

    public function addMessage($messageData, $data = NULL) {
        
    }

    public function removeMessage($message) {
        
    }

    public function getMessage($messageContext = NULL, $data = NULL) {
        
    }

    public function getMessages($messageContext = NULL, $data = NULL) {
        
    }

    /**
     * 
     * @param type $data
     * @return BWMediaManager
     */
    public function getMediaManager($data = NULL){
        if($this->mediaManager == NULL){
            $this->mediaManager = new BWMediaManager($this);            
        }
        return $this->mediaManager;
    }
}

?>
